<?php
// +----------------------------------------------------------------------
// | Longbing [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright Chengdu longbing Technology Co., Ltd.
// +----------------------------------------------------------------------
// | Website http://longbing.org/
// +----------------------------------------------------------------------
// | Sales manager: +86-13558882532 / +86-13330887474
// | Technical support: +86-15680635005
// | After-sale service: +86-17361005938
// +----------------------------------------------------------------------

namespace app\shortvideo\controller;

use app\AdminRest;
use app\passenger\model\AdminActive as PassengerModel;
use app\shortvideo\model\RedbagActive;
use app\shortvideo\model\ReductionActive;
use think\App;

class ActiveList extends AdminRest{

    protected $redbag_model;
    protected $reduction_model;
    protected $passenger_model;

    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->redbag_model         = new RedbagActive();
        $this->reduction_model         = new ReductionActive();
        $this->passenger_model         = new PassengerModel();

        $this->page_size = isset($this->_input['limit'])?$this->_input['limit']:10;
    }

    /**
     **@author lichuanming
     * @DataTime: 2020/5/25 16:28
     * @功能说明: 列表获取
     */
    public function redbagList(){
        $input = $this->_input;
        //uniacid
        $dis[] = ['uniacid','=',$this->_uniacid];
        //查询没有被删除对
        $dis[] = ['status','>',-1];
        //查询
        if(!empty($input['title'])){
            $dis[] = ['title','like',"%".$input['title']."%"];
        }
        //发布者
        if(!empty($input['create_user'])){

            $icon = $input['create_user']==2?'=':'<>';

            $dis[] = ['create_user',$icon,0];
        }
        //查询
        $data  = $this->redbag_model->activeList($dis,$this->page_size);

        return $this->success($data);
    }


    public function passengerList(){
        $input = $this->_input;
        //uniacid
        $dis[] = ['uniacid','=',$this->_uniacid];
        //查询没有被删除对
        $dis[] = ['status','>',-1];
        //查询
        if(!empty($input['title'])){
            $dis[] = ['title','like',"%".$input['title']."%"];
        }
        //查询没有过期的
        $dis[] = ['end_time','>',time()];

        //查询
        $data  = $this->passenger_model->activeList($dis,$this->page_size);

        return $this->success($data);
    }


    public function reductionList(){

        $input = $this->_input;
        //uniacid
        $dis[] = ['uniacid','=',$this->_uniacid];
        //查询没有被删除对
        $dis[] = ['status','=',1];
        //查询
        if(!empty($input['title'])){
            $dis[] = ['title','like',"%".$input['title']."%"];
        }
        //查询
        $data  = $this->reduction_model->activeList($dis,$this->page_size);

        return $this->success($data);
    }
}